//
//  Tjsp_TCell.swift
//  MikerShop
//
//  Created by eme on 2016/12/15.
//  Copyright © 2016年 eme. All rights reserved.
//

/*
 owner:cy
 update:2016年12月15日16:41:41
 info: 推荐商品 cell
 VC :  HomePageVc
 */
import UIKit
import Kingfisher
import RxSwift
import RickonCore
import BrandonCore

class Tjsp_TCell: UITableViewCell {
    
    
    @IBOutlet weak var seperateLine_V: UIView!
    //商品名称
    @IBOutlet weak var pdname_Lb: UILabel!
    //店铺进货价
    @IBOutlet weak var shprice_Lb: UILabel!
    
    @IBOutlet weak var jinPriceImg_V: UIImageView!
    
    //品牌名称
    @IBOutlet weak var brname_Lb: UILabel!
    //起定量
    @IBOutlet weak var mod_Lb: UILabel!
    
    //  利润
    @IBOutlet weak var profit_V: UIView!
    @IBOutlet weak var profit_Lb: UILabel!

    
    @IBOutlet weak var sellout_ImgV: UIImageView!
    @IBOutlet weak var img1_ImgV: UIImageView!
    var item :HpProductModel?{
        didSet{
            if let item = self.item {
                self.pdname_Lb.text = item.pdname
                self.brname_Lb.text = item.brname
                self.mod_Lb.text = "\(item.moq)\(item.pdunit)起批"
                self.img1_ImgV.setUrlImage(item.img1)
                self.profit_Lb.text = "利:\(item.profit.getPriceStr())"
                self.jinPriceImg_V.image = UIImage(named: AppData.getPriceImgName(), in: RobbCore.bundle, compatibleWith: nil)
                self.shprice_Lb.text = AppData.getFinalShowPrice(jinPrice: item.shprice, lingPrice: item.bdprice).getPriceStr()
                if item.stock == 0 || item.pdstate != "3" {
                    self.sellout_ImgV.isHidden = false
                    self.sellout_ImgV.image = UIImage(named: item.stock == 0 ?"sellout":"failure", in: RobbCore.bundle, compatibleWith: nil)
                }else{
                    self.sellout_ImgV.isHidden = true
                }
                if  case .audited = AppData.appState {
                    self.profit_V.isHidden = false
                    /// 1 表示商品 0 表示是仪器等非商品类型
                    self.profit_V.isHidden = item.ptisproduct != "1"
                }else{
                    self.profit_V.isHidden = true
                }
            }
        }
    }
    
    
    override func awakeFromNib() {
        self.seperateLine_V.backgroundColor = Theme.v.separate_Line
        self.profit_V.changeBorderColor(Theme.v.product_li,cornerRadius: 1)
        self.pdname_Lb.normal_fontSize(14)
        self.shprice_Lb.bold_fontSize(14)
        self.brname_Lb.normal_fontSize(13)
        self.mod_Lb.normal_fontSize(13)
        self.profit_Lb.normal_fontSize(11)
    }
}
